﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using M2B.GestionEntretiens.BLL;
using M2B.GestionEntretiens.Contracts;
using M2B.GestionEntretiens.DAL;
using M2B.GestionEntretiens.POCOS;

namespace M2B.GestionEntretiens.Services
{
    /// <summary>
    /// Cette classe implémente le contrat Tests Service
    /// </summary>
    /// <remarks>
    /// Informations de la classe : 
    /// <list type="bullet">
    /// <item name="authors">Auteur : M2B : Maher SAMMARI</item>
    /// <item name="creation date">Date de création : 02/04/2014</item>
    /// <item name="last modification">Date de dernière modification : 02/04/2014</item>
    /// </list>
    /// </remarks>
    public class TestsService : ITestsService
    {
        private readonly IUnitOfWork _unitOfWorky;
        private TestsManager _testsManager;

        public TestsService(IUnitOfWork unitOfWork)
        {
            _unitOfWorky = unitOfWork;
            _testsManager = new TestsManager(_unitOfWorky);

        }
        /// <summary>
        /// Récupération des tests
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Test> GetTests()
        {
            return _testsManager.GetTests("TestQuestions.Question").ToList();
            
        }
        /// <summary>
        /// Ajouter un test
        /// </summary>
        /// <param name="test">Test</param>
        public void AddTest(Test test)
        {
            _testsManager.CreateTest(test);
        }
        /// <summary>
        /// Supprimer un test 
        /// </summary>
        /// <param name="testId">Id Test</param>
        public void DeleteTest(int testId)
        {
           _testsManager.DeleteTest(testId);
        }
        /// <summary>
        /// Mise à jour d'un test
        /// </summary>
        /// <param name="test">Test</param>
        public void Update(Test test)
        {
           _testsManager.UpdateTest(test);
        }
    }
}
